import request from '@/utils/request'

// 获取文章列表
export function getArticleList(params) {
    return request({
        url: '/video/article/list',
        method: 'get',
        params
    })
}

export function importArticles(formData) {
    return request({
        url: '/video/article/import',
        method: 'post',
        data: formData,
        headers: {
            'Content-Type': 'multipart/form-data'
        }
    })
}

// 更新文章状态
export function updateArticleStatus(id, status) {
    return request({
        url: `/video/article/${id}/status`,
        method: 'put',
        params: { status }
    })
}

// 修改文章
export function apiSaveArticle(data) {
    return request({
        url: `/video/article/save`,
        method: 'put',
        data: data
    })
}

// 批量翻译文章
export function apiTranslateArticle(data) {
    return request({
        url: `/video/article/translate/batch`,
        method: 'post',
        data: data
    })
}

// 翻译文章
export function translateArticle(data) {
    return request({
        url: `/video/article/translate`,
        method: 'post',
        data: data
    })
}

// 翻译文本
export function translateText(data) {
    return request({
        url: `/video/article/translate_text`,
        method: 'post',
        data: data
    })
}

export function getArticleTranslations(id) {
    return request({
        url: `/video/article/translations/${id}`,
        method: 'get'
    })
}

export function apiBatchSaveArticles(data) {
    return request({
        url: `/video/article/batch/save`,
        method: 'put',
        data: data
    })
}

// 获取文章详情
export function getArticleDetail(id) {
    return request({
        url: `/video/article/${id}`,
        method: 'get'
    })
}

// 删除文章
export function deleteArticleApi(id) {
    return request({
        url: `/video/article/${id}`,
        method: 'delete'
    })
}

// 批量删除文章
export function batchDeleteArticles(ids) {
    return request({
        url: '/video/article/batch',
        method: 'delete',
        data: { ids }
    })
}